<template>
  <div v-show="id">
    <h3>押金垫付设置</h3>
    <p>服务区域：{{ptCashPrePay.cityCodesValue}}</p>
    <p>服务次数：{{ptCashPrePay.serverTimesValue}}</p>
    <p>等待期：{{ptCashPrePay.waitMonthsValue}}</p>
    <p>沟通确认提示文案: {{ptCashPrePay.remark || '无'}}</p>
    <p v-if="Array.isArray(ptCashPrePay.carryInfoList) && ptCashPrePay.carryInfoList.length">携带文件：</p>
    <el-row :gutter="20" v-for="(filesData, index) in ptCashPrePay.carryInfoList" :key="index" style="margin-bottom: 10px">
      <el-col :span="6">
        文件名：{{filesData.name}}
      </el-col>
      <el-col :span="10">
        模板链接：<a :href="filesData.link">{{filesData.link}}</a>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'youPash',
  props: {
    id: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      ptCashPrePay: {}
    }
  },
  methods: {
    getData () {
      this.axios.get(`/goods/cashPrePay/${this.id}`).then((res) => {
        const code = Number(res.data.code)
        if (code === 200) {
          this.ptCashPrePay = res.data.data
          this.ptCashPrePay.cityCodesValue = this.ptCashPrePay.cityCodes == '-1' ? '全国' : this.ptCashPrePay.cityCodes
          this.ptCashPrePay.serverTimesValue = this.ptCashPrePay.serverTimes == '-1' ? '不限' : (this.ptCashPrePay.serverTimes + '次')
          this.ptCashPrePay.waitMonthsValue = this.ptCashPrePay.waitMonths == '-1' ? '无' : (this.ptCashPrePay.waitMonths + '天')
          this.ptCashPrePay.carryInfoList = JSON.parse(this.ptCashPrePay.carryInfoList)
        } else {
          this.$message(this.mes.busy)
        }
      }).catch((err) => {
        console.log(err)
        this.$message(this.mes.busy)
      })
    }
  },
  watch: {
    id() {
      this.getData()
    }
  }
}
</script>

<style>

</style>
